<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
</head>
<script type="text/javascript" src="../js/util.js"></script>
<script type="text/javascript">
    function copy2wps(){
        alert(1)
         let doc = wps.WpsApplication().ActiveDocument
         if (doc){
             var iframe = document.getElementsByTagName("iframe")[0];
             var win = iframe.contentWindow; // 通过contentWindow获取ifame子页面的window窗体对象。(不允许跨域名访问)
             var iframeDocument = iframe.contentWindow.document;
             var input1 = iframeDocument.getElementById("write").innerHTML;
            doc.Range(0, 0).Text=input1
            //好像是wps的bug, 这两句话触发wps重绘
            let rgSel = wps.WpsApplication().Selection.Range
            if (rgSel)
             rgSel.Select()
         }
    }
</script>
<!-- <script type="text/javascript" src="../js/taskpane.js"></script> -->

<body>
    <div class="global">
        <button id="copy2wps" onclick="copy2wps();">把这个页面的源码插入活动文档</button>
        <iframe id="test"
            src="http://127.0.0.1:8080/browser-integration-wps/" width="100%" height="800px"></iframe>

    </div>
</body>

<style>
    .global {
        font-size: 15px;
        min-height: 95%;
    }

    .divItem {
        margin-left: 5px;
        margin-bottom: 18px;
        font-size: 15px;
        word-wrap: break-word;
    }
</style>

</html>
